home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from cStringIO import StringIO
-
- class chained_files(object):
-
- def __init__(self, fileobjs):
- self._bytecount = 0
- self.fileobjs = []
- for obj in fileobjs:
- if not hasattr(obj, 'read') and isinstance(obj, str):
- self.fileobjs.append(StringIO(obj))
- else:
- self.fileobjs.append(obj)
- if not hasattr(self.fileobjs[-1], 'read'):
- raise TypeError('chained_files makes a .read object out of .read objects only. got a %r', obj)
-
- if hasattr(obj, 'tell'):
- self._bytecount += obj.tell()
- continue
- self
- print '%s object %r has no attribute tell' % (type(obj), obj)
-
- self.obj = self.fileobjs.pop(0)
-
-
- def read(self, blocksize = -1):
- pass
-
-
- def tell(self):
- return self._bytecount
-
-
-
- class AttrChain(object):
-
- def __init__(self, name, parent):
- self.name = name
- self.parent = parent
-
-
- def __getattr__(self, attr):
- if attr == '_getAttributeNames':
- return False
-
- return None(AttrChain if self.name is not None else '' + attr, self.parent)
-
-
- def __call__(self, *a, **k):
- return self.parent(self.name, *a, **k)
-
-
-
- class ObjectList(list):
-
- def __init__(self, *a, **k):
- self.__dict__['strict'] = k.pop('strict', True)
- list.__init__(self, *a, **k)
-
-
- def __setattr__(self, attr, val):
- for o in self:
- setattr(o, attr, val)
-
-
-
- def __getattr__(self, attr):
-
- try:
- return list.__getattr__(self, attr)
- except AttributeError:
-
- try:
- return self.__dict__[attr]
- except KeyError:
- if self.__dict__.get('strict', True):
- default = sentinel
- else:
-
- default = lambda *a, **k: pass
- res = (ObjectList,)((lambda .0: for x in .0:
- getattr(x, attr, sentinel))(self))
- if self.__dict__.get('strict', True) and sentinel in res:
- raise AttributeError('Not all objects in %r have attribute %r' % (self, attr))
-
-
- try:
- res = FunctionList(res)
- except AssertionError:
- pass
-
- return res
- except:
- None<EXCEPTION MATCH>KeyError
-
-
- None<EXCEPTION MATCH>KeyError
-
-
-
- def __repr__(self):
- return '<%s: %r>' % (type(self).__name__, list.__repr__(self))
-
-
-
- class FunctionList(ObjectList):
-
- def __init__(self, *a, **k):
- ObjectList.__init__(self, *a, **k)
- if not all((lambda .0: for x in .0:
- callable(x))(self)):
- raise AssertionError
-
-
-
- def __call__(self, *a, **k):
- return [ f(*a, **k) for f in self ]
-
-
-
- def compose(funcs):
-
- def composed(res):
- for f in funcs:
- res = f(res)
-
- return res
-
- return composed
-
-
- def chain(*iterables):
- for it in iterables:
- for element in it:
- yield element
-
-
-
-
- def main():
- chained = chained_files((lambda .0: for s in .0:
- StringIO(s))('one two three'.split()))
- print chained.read(8)
- print chained.read(8)
-
- if __name__ == '__main__':
- main()
-
-